﻿using Dapper;
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WebAppMVC5EF62.FBDbContext;
using WebAppMVC5EF62.Models;

namespace WebAppMVC5EF62.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            /*
            List<UserModel> userList = null;
            using (MySqlConnection connection = new MySqlConnection("Data Source=222.73.236.109;Database=cms_mvn;User Id=root;Password=LXYG5QF@qsgct1s;CharSet=utf8;Port=3306"))
            {
                string sql = "SELECT so_name AS Name,so_account AS Account,so_type AS Type FROM sys_user";
                userList = connection.Query<UserModel>(sql).ToList();
            }

            System.Diagnostics.Debug.WriteLine(userList);
            System.Diagnostics.Debug.WriteLine(userList == null);
            System.Diagnostics.Debug.WriteLine(userList.Count);
            */

            var context = new FBContext();

            List<UserModel> userList = context.UserModel.AsList<UserModel>();

            System.Diagnostics.Debug.WriteLine(userList);
            System.Diagnostics.Debug.WriteLine(userList == null);
            System.Diagnostics.Debug.WriteLine(userList.Count);

            return View();
        }

        public ActionResult About()
        {
            ViewBag.Message = "Your application description page.";

            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }
    }
}